<template>
    <table class="table table-bordered">
        <tbody>
            <tr>
                <td>登录名</td>
                <td>
                    <input type="text" v-model="queryInfo.userName" >
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input  type="password"  v-model="queryInfo.usePwd" >
                </td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <input type="button" @click="Den" class="btn btn-success" value="登录">
                </td>
            </tr>
        </tbody>
    </table>
</template>

<script setup lang="ts">
import{ref,reactive} from 'vue';
import axios from 'axios';
import {useRouter} from 'vue-router';
const router=useRouter();
let queryInfo=reactive({
    userName:'',
    usePwd:'',
})
const Den=()=>{
    if(queryInfo.userName==""){
        alert("用户名不能为空");
        return;
    }
    if(queryInfo.usePwd==""){
        alert("密码不能为空");
        return;
    }
    axios({
        url:'https://localhost:7001/api/Admin/Login',
        method:'get',
        params:{
            userName:queryInfo.userName,
            usePwd:queryInfo.usePwd,
        }
    })
    .then(res=>{
        if(res.data==-1){
            alert("账号不存在");
            return;
        }
    })
    .catch(res=>{
        if(res.data==-1){
            alert("密码错误!");
            return;
        }
        router.push('/member')
    })
}
</script>

<style scoped>

</style>